//---------------------------------------------------------------------
// This file is part of the Microsoft BizTalk Server 2006 SDK
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
// This source code is intended only as a supplement to Microsoft BizTalk
// Server 2006 release and/or on-line documentation. See these other
// materials for detailed information regarding Microsoft code samples.
//
// THIS CODE AND INFORMATION ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY
// KIND, WHETHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
// IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR
// PURPOSE.
//---------------------------------------------------------------------
using System;
using System.IO;
using EnvDTE;
using System.Windows.Forms;
using System.Runtime.InteropServices;  
using Microsoft.BizTalk.Wizard;
using VSLangProj;
using Microsoft.Win32;
using System.Diagnostics;
using System.Collections.Specialized;
using System.Resources;
using System.Reflection;
using System.Text;
using System.Xml;
using System.Collections;
using System.Collections.Generic;

namespace MsPartners.Unisys.BizTalkAdapters.AdapterWizard
{
	public delegate void AddWizardResultEvent(object sender,PropertyPairEvent e);
	public delegate void AddTransmitHandlerPropertyEvent(object sender,PropertyPairEvent e);
	public delegate void AddTransmitEndpointPropertyEvent(object sender,PropertyPairEvent e);
	public delegate void AddReceiveHandlerPropertyEvent(object sender,PropertyPairEvent e);
	public delegate void AddReceiveEndpointPropertyEvent(object sender,PropertyPairEvent e);
	
	enum SupportedLanguages
	{
		CSharp,
		VisualBasicNET
	}
	/// <summary>
	/// List of constants to find values in the List<AdapterProperty>
	/// </summary>
	internal class WizardValues
	{
		public const string TransportType = "TransportType";
		public const string Aliases = "Aliases";
		public const string PropertyNamespace = "PropertyNamespace";
		
		public const string AdapterIsTransmitAdapter = "AdapterIsTransmitAdapter";
		public const string AdapterIsReceiveAdapter = "AdapterIsReceiveAdapter";
		public const string TransmitAdapterSupportsSolRsp = "TransmitAdapterSupportsSolRsp";
		public const string TransmitAdapterHasExtendedBatchSupport = "TransmitAdapterHasExtendedBatchSupport";
		public const string TransmitAdapterDescription = "TransmitAdapterDescription";
		public const string ReceiveAdapterSupportsReqRsp = "ReceiveAdapterSupportsReqRsp";
		public const string ReceiveAdapterIsIsolated = "ReceiveAdapterIsIsolated";
		public const string ReceiveAdapterDescription = "ReceiveAdapterDescription";
		
		public const string NewProjectNamespace = "NewProjectNamespace";
		public const string GeneratedLanguage = "GeneratedLanguage";

		public const string TransmitHandlerProperty = "TransmitHandlerProperty";
		public const string TransmitEndpointProperty = "TransmitEndpointProperty";
		public const string ReceiveHandlerProperty = "ReceiveHandlerProperty";
		public const string ReceiveEndpointProperty = "ReceiveEndpointProperty";
	}
	/// <summary>
	/// Class (com-object) called by VS2005 to start a new adapter project.
	/// </summary>
	[ProgId("VSWizard.BizTalkAdapterWizard")]
	public class BizTalkAdapterWizard : IDTWizard
	{
		enum ContextOptions
		{
			WizardType,
			ProjectName, 
			LocalDirectory,
			InstallationDirectory,
			FExclusive,
			SolutionName,
			Silent
		}

		private string transportType = null;
		private string newProjectNamespace = null;
		private string propertyNamespace = null;
		private string aliases = null;

		private string transmitAdapterDescription = null;
		private string receiveAdapterDescription = null;

		private bool adapterIsTransmitAdapter = false;
		private bool adapterIsReceiveAdapter = false;
		private bool transmitAdapterSupportsSolRsp = false;
		private bool transmitAdapterhasExtendedBatchSupport = false;
		private bool receiveAdapterSupportsReqRsp = false;
		private bool receiveAdapterIsIsolated = false;

		private string bizTalkInstallPath = null;
		private string visualStudioInstallPath = null;
		private string projectFolder = null;
		private string projectName = null;
		private string solutionName = null;
		private SupportedLanguages codeLanguage = SupportedLanguages.CSharp;

		bool fExclusive = false;
		private Solution adapterSolution = null;
		private ResourceTemplate resourceTemplate = null;
		private AdapterRegistry adapterRegistry = null;

		private Hashtable wizardResults = null;
		private List<AdapterProperty> transmitHandlerProperties = null;
		private List<AdapterProperty> transmitEndpointProperties = null;
		private List<AdapterProperty> receiveHandlerProperties = null;
		private List<AdapterProperty> receiveEndpointProperties = null;
		
		public BizTalkAdapterWizard()
		{
			const string bizTalkKey = @"SOFTWARE\Microsoft\BizTalk Server\3.0";
			RegistryKey bizTalkReg = Registry.LocalMachine.OpenSubKey(bizTalkKey);
			bizTalkInstallPath = bizTalkReg.GetValue("InstallPath").ToString();
			bizTalkReg.Close();

			const string visualStudioKey = @"SOFTWARE\Microsoft\VisualStudio\8.0";
			RegistryKey visualStudioReg = Registry.LocalMachine.OpenSubKey(visualStudioKey);
			visualStudioInstallPath = visualStudioReg.GetValue("InstallDir").ToString();
			visualStudioReg.Close();
		}

		/// <summary>
		/// Main function for wizard project. Calls the wizard-
		/// form and then delegates control to the createsolution function
		/// </summary>
		/// <param name="Application"></param>
		/// <param name="hwndOwner"></param>
		/// <param name="contextParams"></param>
		/// <param name="CustomParams"></param>
		/// <param name="retval"></param>
		public void Execute(object Application, int hwndOwner, ref object[] contextParams, ref object[] CustomParams, ref EnvDTE.wizardResult retval)
		{
			_DTE IDEObject = (_DTE)Application;

			try
			{
				AdapterWizardForm wizardForm = new AdapterWizardForm();
				if (wizardForm.ShowDialog() == DialogResult.OK)
				{
					//Retrieve the wizard data
					wizardResults = wizardForm.WizardResults;
					transmitHandlerProperties = wizardForm.TransmitHandlerProperties;
					transmitEndpointProperties = wizardForm.TransmitEndpointProperties;
					receiveHandlerProperties = wizardForm.ReceiveHandlerProperties;
					receiveEndpointProperties = wizardForm.ReceiveEndpointProperties;

					//Create the solution
					CreateSolution(IDEObject,contextParams);
					retval = wizardResult.wizardResultSuccess;
				}
				else
				{
					retval = wizardResult.wizardResultCancel;					
					return;
				}

			}
			catch (Exception err)
			{
				Trace.Write(err.Message);
				MessageBox.Show(err.Message, "BizTalk Server Adapter Wizard");
				Trace.WriteLine(err.Message + Environment.NewLine + err.StackTrace);
				retval = wizardResult.wizardResultFailure;
			}
		}
	
		/// <summary>
		/// Creates the solution and calls the functions to create the projects
		/// </summary>
		/// <param name="IDEObject"></param>
		/// <param name="contextParams"></param>
		public void CreateSolution(_DTE IDEObject,object[] contextParams)
		{
			string solutionFolder = "";
			TraceAllValues(contextParams);
			//Get the "official" wizard results
			projectFolder = contextParams[(int)ContextOptions.LocalDirectory].ToString();
			projectName = contextParams[(int)ContextOptions.ProjectName].ToString();
			solutionName = contextParams[(int)ContextOptions.SolutionName].ToString();
			fExclusive = bool.Parse(contextParams[(int)ContextOptions.FExclusive].ToString());	

			//Get the custom wizard results
			transportType = wizardResults[WizardValues.TransportType].ToString();
			newProjectNamespace = wizardResults[WizardValues.NewProjectNamespace].ToString();
			propertyNamespace = wizardResults[WizardValues.PropertyNamespace].ToString();

			codeLanguage = (wizardResults[WizardValues.GeneratedLanguage].ToString() == "True" ? SupportedLanguages.CSharp : SupportedLanguages.VisualBasicNET);
			//If transmit was chosen, get the transmit wizard results
			adapterIsTransmitAdapter = (wizardResults[WizardValues.AdapterIsTransmitAdapter].ToString() == "True");
			if (adapterIsTransmitAdapter)
			{
				transmitAdapterSupportsSolRsp = (wizardResults[WizardValues.TransmitAdapterSupportsSolRsp].ToString() == "True");
				transmitAdapterhasExtendedBatchSupport = (wizardResults[WizardValues.TransmitAdapterHasExtendedBatchSupport].ToString() == "True");
				transmitAdapterDescription = wizardResults[WizardValues.TransmitAdapterDescription].ToString();
				aliases = wizardResults[WizardValues.Aliases].ToString();
			}
			else
			{
				//Clear unused collections
				transmitHandlerProperties = new List<AdapterProperty>();
				transmitEndpointProperties = new List<AdapterProperty>();
			}

			//If receive was chosen, get the receive wizard results
			adapterIsReceiveAdapter = (wizardResults[WizardValues.AdapterIsReceiveAdapter].ToString() == "True");
			if (adapterIsReceiveAdapter)
			{
				receiveAdapterSupportsReqRsp = (wizardResults[WizardValues.ReceiveAdapterSupportsReqRsp].ToString() == "True");
				receiveAdapterIsIsolated = (wizardResults[WizardValues.ReceiveAdapterIsIsolated].ToString() == "True");
				receiveAdapterDescription = wizardResults[WizardValues.ReceiveAdapterDescription].ToString();
			}
			else
			{
				//Clear unused collections
				receiveHandlerProperties = new List<AdapterProperty>();
				receiveEndpointProperties = new List<AdapterProperty>();
			}

			//Fix the solution path if it is doubled
			if (solutionName == projectName)
				solutionFolder = projectFolder.Remove(projectFolder.LastIndexOf(projectName) - 1);
			else
				solutionFolder = projectFolder;

			//Create the AdapterRegistry class for future use
			adapterRegistry = new AdapterRegistry();
			adapterRegistry.RequestedLanguage = codeLanguage;
			
			//Create the resource template class and load it with the wizard values
			if (codeLanguage == SupportedLanguages.CSharp)
			{
				resourceTemplate = new CSResourceTemplate();
			}
			else
			{
				resourceTemplate = new CSResourceTemplate();//VBResourceTemplate();
			}

			resourceTemplate.TransportType = transportType;
			resourceTemplate.PropertyNamespace = propertyNamespace;
			resourceTemplate.NewProjectNamespace = newProjectNamespace;

			if (adapterIsTransmitAdapter)
			{
				resourceTemplate.TransmitAdapterDescription = wizardResults[WizardValues.TransmitAdapterDescription].ToString();
				resourceTemplate.TransmitHandlerProperties = transmitHandlerProperties;
				resourceTemplate.TransmitEndpointProperties = transmitEndpointProperties;
				resourceTemplate.OutboundCLSID = adapterRegistry.OutboundCLSID;
				resourceTemplate.TransmitAdapterhasExtendedBatchSupport = transmitAdapterhasExtendedBatchSupport;
			}
			if (adapterIsReceiveAdapter)
			{
				resourceTemplate.ReceiveAdapterDescription = wizardResults[WizardValues.ReceiveAdapterDescription].ToString();

				resourceTemplate.ReceiveHandlerProperties = receiveHandlerProperties;
				resourceTemplate.ReceiveEndpointProperties = receiveEndpointProperties;

				resourceTemplate.InboundCLSID = adapterRegistry.InboundCLSID;
				resourceTemplate.ReceiveAdapterIsInProcess = !receiveAdapterIsIsolated;
				resourceTemplate.ReceiveAdapterSupportsReqRsp = receiveAdapterSupportsReqRsp;
			}

			if (!fExclusive)//New solution or existing?
			{
				// Get a reference to the solution from the IDE Object
				adapterSolution = IDEObject.Solution; 
			}
			else
			{
				// Use the solution class to create a new solution 
				adapterSolution = IDEObject.Solution;
				adapterSolution.Create(solutionFolder, solutionName.Length !=0 ? solutionName : projectName);
			}

			//Create the projects
			
			CreateDesignTimeProject();
			
			if (adapterIsTransmitAdapter)
			{
				CreateTransmitAdapterProject();
			}
			if (adapterIsReceiveAdapter)
			{
				CreateReceiveAdapterProject();
			}
			// Save the solution file
			adapterSolution.SaveAs(solutionFolder + "\\" + 
				(solutionName.Length != 0 ? solutionName : projectName) + ".sln");
			
			// Save the registry file
			adapterRegistry.AdapterSupportsReceive = adapterIsReceiveAdapter;
			adapterRegistry.AdapterSupportsTransmit = adapterIsTransmitAdapter;
			adapterRegistry.Aliases = aliases;
			adapterRegistry.CodeNamespace = newProjectNamespace;
			adapterRegistry.ProjectDirectory = projectFolder;
			adapterRegistry.PropertyNamespace = propertyNamespace;
			adapterRegistry.ReceiveAdapterIsIsolated = receiveAdapterIsIsolated;
			adapterRegistry.ReceiveAdapterSupportsReqRsp = receiveAdapterSupportsReqRsp;
			adapterRegistry.TransmitAdapterSupportsSolRsp = transmitAdapterSupportsSolRsp;
			adapterRegistry.TransportType = transportType;
			adapterRegistry.ReceiveAdapterHasHandler = (receiveHandlerProperties.Count > 0);
			adapterRegistry.TransmitAdapterHasHandler = (transmitHandlerProperties.Count > 0);
			adapterRegistry.CreateRegFile(projectFolder + "\\" + transportType + "Adapter.reg");
		}

		/// <summary>
		/// Creates the designtime project and adds the appropriate files to the
		/// project.
		/// </summary>
		public void CreateDesignTimeProject()
		{
			string relativePath = null;
			string projectFileName = null;
			string extension = null;
			if (codeLanguage == SupportedLanguages.CSharp)
			{
				relativePath = "CSTemplates.DesignTime";
				projectFileName = "AdapterManagement._csproj";
				extension = "_cs";
			}
			else
			{
				relativePath = "VBTemplates.DesignTime";
				projectFileName = "AdapterManagement._vbproj";
				extension = "_vb";
			}

			string designTimeDirPath = projectFolder + @"\Design-Time";

			DirectoryInfo DesignTimeDir = new DirectoryInfo(designTimeDirPath);
			// Create the directory only if it does not already exist.
			if (DesignTimeDir.Exists == false)
				DesignTimeDir.Create();

			// Create the projectfile for the solution
			resourceTemplate.Render(projectFileName,relativePath,
				designTimeDirPath,false);

			EnvDTE.Project adapterProject = 
				adapterSolution.AddFromFile(designTimeDirPath + 
					@"\" + projectFileName.Replace("._","."),false);

			// Get a reference to the Visual Studio Project and 
			// use it to add a reference to the framework assemblies
			VSProject adapterVSProject = (VSProject)adapterProject.Object;
			
			adapterVSProject.References.Add("Microsoft.Biztalk.Adapter.Framework");  
			adapterVSProject.References.Add("Microsoft.BizTalk.Pipeline");
			try
			{
				adapterVSProject.References.Add(bizTalkInstallPath +
					@"SDK\Samples\AdaptersDevelopment\BaseAdapter\v1.0.2\bin\Release\Microsoft.Samples.BizTalk.Adapter.Common.dll");
			}
			catch
			{
				MessageBox.Show(
					"The file: \"Microsoft.Samples.BizTalk.Adapter.Common.dll\"" +
					" could not be found. Please add it later using \"Add reference\".",
					"Project: " + transportType + "TransmitAdapter");
			}

  
			resourceTemplate.RenderAndAddToProject("AdapterManagement." + extension,
				relativePath,DesignTimeDir.FullName,adapterVSProject,false,false);
			resourceTemplate.RenderAndAddToProject("AssemblyInfo." + extension,
				relativePath,DesignTimeDir.FullName,adapterVSProject,false,false);

			resourceTemplate.RenderAndAddToProject("AdapterResource._resx",
				relativePath, DesignTimeDir.FullName, adapterVSProject, true, true);
			
			if (adapterIsTransmitAdapter)
			{
				resourceTemplate.RenderAndAddToProject("TransmitHandler._xsd",
					relativePath,DesignTimeDir.FullName,adapterVSProject,true,false);
				resourceTemplate.RenderAndAddToProject("TransmitLocation._xsd",
					relativePath,DesignTimeDir.FullName,adapterVSProject,true,false);
			}
			if (adapterIsReceiveAdapter)
			{
				resourceTemplate.RenderAndAddToProject("ReceiveHandler._xsd",
					relativePath,DesignTimeDir.FullName,adapterVSProject,true,false);
				if (receiveAdapterIsIsolated)
				{
					resourceTemplate.RenderAndAddToProject("IH__ReceiveLocation._xsd",
						relativePath, DesignTimeDir.FullName, adapterVSProject, true, false);
				}
				else
				{
					resourceTemplate.RenderAndAddToProject("IP__ReceiveLocation._xsd",
						relativePath, DesignTimeDir.FullName, adapterVSProject, true, false);
				}
			}
			// Save the project file
			adapterVSProject.Project.Save(projectFolder + @"\Design-Time\" + projectFileName.Replace("._",".")); 
		}

		/// <summary>
		/// Creates the transmit adapter project
		/// </summary>
		private void CreateTransmitAdapterProject()
		{
			string relativePath = null;
			string projectFileName = null;
			string extension = null;
			if (codeLanguage == SupportedLanguages.CSharp)
			{
				relativePath = "CSTemplates.Runtime.TransmitAdapter";
				projectFileName = "TransmitAdapter._csproj";
				extension = "_cs";
			}
			else
			{
				relativePath = "VBTemplates.Runtime.TransmitAdapter";
				projectFileName = "TransmitAdapter._vbproj";
				extension = "_vb";
			}
			
			string transmitAdapterDirPath = projectFolder + @"\Run-Time\" + 
				transportType + "Transmit";

			// Create the runtime and adapter management directories
			DirectoryInfo transmitDir = new DirectoryInfo(transmitAdapterDirPath);
			// Create the directory only if it does not already exist.
			if (transmitDir.Exists == false)
				transmitDir.Create();

			// Create the projectfile for the solution
			resourceTemplate.Render(projectFileName,relativePath,
				transmitAdapterDirPath,true);

			EnvDTE.Project adapterProject = 
				adapterSolution.AddFromFile(transmitAdapterDirPath + 
				@"\" + transportType + projectFileName.Replace("._","."),false);

			// Get a reference to the Visual Studio Project and 
			// use it to add a reference to the XML assembly
			VSProject adapterVSProject = (VSProject)adapterProject.Object;
			
			try
			{
				adapterVSProject.References.Add(bizTalkInstallPath + 
					@"SDK\Samples\AdaptersDevelopment\BaseAdapter\v1.0.2\bin\Release\Microsoft.Samples.BizTalk.Adapter.Common.dll");  
			}
			catch
			{
				MessageBox.Show(
					"The file: \"Microsoft.Samples.BizTalk.Adapter.Common.dll\"" + 
					" could not be found. Please add it later using \"Add reference\".",
					"Project: " + transportType + "TransmitAdapter");
			}
			adapterVSProject.References.Add("Microsoft.BizTalk.Streaming");
			adapterVSProject.References.Add("Microsoft.BizTalk.GlobalPropertySchemas");
			adapterVSProject.References.Add("Microsoft.BizTalk.Interop.TransportProxy");  
			adapterVSProject.References.Add("Microsoft.XLANGs.BaseTypes");  
			adapterVSProject.References.Add("Microsoft.BizTalk.Pipeline");  

			string [] simpleBatchTransmitResources = 
			{
				"AdapterExceptions.",
				"AssemblyInfo.",
				"TransmitAdapterBatch.",
				"TransmitProperties.",
				"Transmitter.",
				"TransmitterEndpoint."
			};

			string [] extendedBatchTransmitResources = 
			{
				"AdapterExceptions.",
				"AssemblyInfo.",
				"TransmitAsyncBatch.",
				"TransmitProperties.",
				"Transmitter."
			};

			string []transmitResources = null;
			if (transmitAdapterhasExtendedBatchSupport)
			{
				transmitResources = extendedBatchTransmitResources;
			}
			else
			{
				transmitResources = simpleBatchTransmitResources;
			}
			
			foreach(string resourceName in transmitResources)
			{
				string newFile = resourceTemplate.Render(resourceName + extension,
					relativePath,transmitAdapterDirPath,
					!resourceName.StartsWith("AssemblyInfo"));
				// Add the sourcefile to the project
				EnvDTE.ProjectItem adapterProjectItem =  
					adapterVSProject.Project.ProjectItems.AddFromFile(newFile);
			}

			// Save the project file
			adapterVSProject.Project.Save(transmitAdapterDirPath + 
				@"\" + transportType + projectFileName.Replace("._",".")); 
		}	

		/// <summary>
		/// Creates the receive adapter project
		/// </summary>
		private void CreateReceiveAdapterProject()
		{
			string relativePath = null;
			string projectFileName = null;
			string extension = null;
			if (codeLanguage == SupportedLanguages.CSharp)
			{
				relativePath = "CSTemplates.Runtime.ReceiveAdapter";
				projectFileName = "ReceiveAdapter._csproj";
				extension = "_cs";
			}
			else
			{
				relativePath = "VBTemplates.Runtime.ReceiveAdapter";
				projectFileName = "ReceiveAdapter._vbproj";
				extension = "_vb";
			}

			string receiveAdapterDirPath = projectFolder + @"\Run-Time\" + 
				transportType + "Receive";

			// Create the runtime and adapter management directories
			DirectoryInfo receiveDir = new DirectoryInfo(receiveAdapterDirPath);
			// Create the directory only if it does not already exist.
			if (receiveDir.Exists == false)
				receiveDir.Create();

			// Create the projectfile for the solution
			resourceTemplate.Render(projectFileName,relativePath,
				receiveAdapterDirPath,true);

			EnvDTE.Project adapterProject = 
				adapterSolution.AddFromFile(receiveAdapterDirPath + 
				@"\" + transportType + projectFileName.Replace("._","."),false);

			// Get a reference to the Visual Studio Project and 
			// use it to add a reference to the XML assembly
			VSProject adapterVSProject = (VSProject)adapterProject.Object;
			
			try
			{
				adapterVSProject.References.Add(bizTalkInstallPath + 
					@"SDK\Samples\AdaptersDevelopment\BaseAdapter\v1.0.2\bin\Release\Microsoft.Samples.BizTalk.Adapter.Common.dll");  
			}
			catch
			{
				MessageBox.Show(
					"The file: \"Microsoft.Samples.BizTalk.Adapter.Common.dll\"" + 
					" could not be found. Please add it later using \"Add reference\".",
					"Project: " + transportType + "ReceiveAdapter");
			}
			adapterVSProject.References.Add("Microsoft.BizTalk.Interop.TransportProxy");  
			adapterVSProject.References.Add("Microsoft.XLANGs.BaseTypes");  
			adapterVSProject.References.Add("Microsoft.BizTalk.Pipeline");  
			adapterVSProject.References.Add("Microsoft.BizTalk.GlobalPropertySchemas.dll");  

			string [] isolatedReceiveResources = 
			{
				"AssemblyInfo.",
				"MsgContext.",
				"IH__Receiver.",
				"IH__ReceiverEndpoint.",
				"ReceiveProperties.",
				"ResponseHandler."
			};

			string [] regularReceiveResources = 
			{
				"AssemblyInfo.",
				"IP__Receiver.",
				"IP__ReceiverEndpoint.",
				"ReceiveProperties.",
				"ResponseHandler."
			};

			string []receiveResources = null;
			if (receiveAdapterIsIsolated)
			{
				receiveResources = isolatedReceiveResources;
			}
			else
			{
				receiveResources = regularReceiveResources;
			}

			foreach(string resourceName in receiveResources)
			{
				if (!receiveAdapterSupportsReqRsp && resourceName == "ResponseHandler.")
					continue;
				string newFile = resourceTemplate.Render(resourceName + extension,
					relativePath,receiveAdapterDirPath,
					!resourceName.StartsWith("AssemblyInfo"));
				// Add the C# file to the project
				EnvDTE.ProjectItem AdapterProjectItem =  
					adapterVSProject.Project.ProjectItems.AddFromFile(newFile);
			}

			// Save the project file
			adapterVSProject.Project.Save(receiveAdapterDirPath + 
				@"\" + transportType + projectFileName.Replace("._",".")); 
		}
	
		/// <summary>
		/// This will dump all of the values in the namedvaluecollections
		/// and in the contextparams coll. to the debug window 
		/// (or better: debugview).
		/// </summary>
		/// <param name="contextParams"></param>
		private void TraceAllValues(object[] contextParams)
		{
			return;
			/*
			Trace.WriteLine("++ Start contextParams");
			foreach(object o in contextParams)
			{
				Trace.WriteLine(o.ToString());
			}
			Trace.WriteLine("-- End contextParams");

			Trace.WriteLine("++ Start wizardResults");
			foreach(object o in wizardResults)
			{
				Trace.WriteLine("Name:" + o.ToString() + " - Value = " + wizardResults[o].ToString());
			}
			Trace.WriteLine("-- End wizardResults");

			Trace.WriteLine("++ Start transmitHandlerProperties");
			foreach(object o in transmitHandlerProperties)
			{
				Trace.WriteLine("Name:" + o.ToString() + " - Value = " + transmitHandlerProperties[o].ToString());
			}
			Trace.WriteLine("-- End transmitHandlerProperties");

			Trace.WriteLine("++ Start transmitEndpointProperties");
			foreach(object o in transmitEndpointProperties)
			{
				Trace.WriteLine("Name:" + o.ToString() + " - Value = " + transmitEndpointProperties[o].ToString());
			}
			Trace.WriteLine("-- End receiveEndpointProperties");

			Trace.WriteLine("++ Start receiveHandlerProperties");
			foreach(object o in receiveHandlerProperties)
			{
				Trace.WriteLine("Name:" + o.ToString() + " - Value = " + receiveHandlerProperties[o].ToString());
			}
			Trace.WriteLine("-- End receiveHandlerProperties");

			Trace.WriteLine("++ Start receiveHandlerProperties");
			foreach(object o in receiveHandlerProperties)
			{
				Trace.WriteLine("Name:" + o.ToString() + " - Value = " + receiveHandlerProperties[o].ToString());
			}
			Trace.WriteLine("-- End receiveHandlerProperties");
			 */
		}
		
		/// <summary>
		/// Checks if there is a release build for the base-adapter. If not,
		/// a dialog appears to point to the right place.
		/// OBSOLETE
		/// </summary>
		private bool CheckForBaseAdapter()
		{
			FileInfo BaseAdapterBuild = new FileInfo(bizTalkInstallPath + 
				@"SDK\Samples\Adapters\Common\BaseAdapter\v1.0.1\" +
				@"bin\Release\Microsoft.Samples.BizTalk.Adapter.Common.dll");
			if (!BaseAdapterBuild.Exists)
			{

			}
			return false;
		}
	}
}
